--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Volumes/JSS/Staiger Productivity/stage3_6may2014.log
  log type:  text
 opened on:  15 Dec 2014, 12:15:58

. * this is stage3 program, 3 nov 2008
. * Assumes that stage1 and stage2 (and stent_staiger) have already been run
. set more off 

. clear all

. set mem 200m

Current memory allocation

                    current                                 memory usage
    settable          value     description                 (1M = 1024k)
    --------------------------------------------------------------------
    set maxvar        10000     max. variables allowed           4.208M
    set memory          200M    max. data space                200.000M
    set matsize         400     max. RHS vars in models          1.254M
                                                            -----------
                                                               205.462M

. use aha94

. gen provider=real(hcfaid)

. drop hcfaid

. gen forprof=(cntrl>=31 & cntrl<=33)

. gen govt=((cntrl>=11 & cntrl<=16)|(cntrl>=41 & cntrl<=48))

. sort provider

. save aha94_1, replace
file aha94_1.dta saved

. 
. use analysis_1986_2_2014

. sort provider

. merge provider using aha94_1
variable provider does not uniquely identify observations in the master data
variable provider does not uniquely identify observations in aha94_1.dta

. tab _merge

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      2,280        4.07        4.07
          2 |      3,431        6.13       10.20
          3 |     50,255       89.80      100.00
------------+-----------------------------------
      Total |     55,966      100.00

. drop if _merge==2
(3431 observations deleted)

. drop _merge

. replace teaching=0 if teaching==.
(2280 real changes made)

. replace forprof=0 if forprof==.
(2280 real changes made)

. 
. 
. rename f_joint1 f_level

. rename f_joint1_5 f_level_5

. *rename f_level1 f_level
. *rename f_level1_5 f_level_5
. rename f_joint2 f_bad

. rename f_joint2_5 f_bad_5

. tab f_level_5, gen(q_)

5 quantiles |
of f_joint1 |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     15,466       29.44       29.44
          2 |     10,754       20.47       49.91
          3 |      9,424       17.94       67.85
          4 |      9,006       17.14       84.99
          5 |      7,885       15.01      100.00
------------+-----------------------------------
      Total |     52,535      100.00

. tsset provider year
       panel variable:  provider (strongly balanced)
        time variable:  year, 1986 to 2004
                delta:  1 unit

. 
. 
. * Create survival, cost & drg measures (fe + mean in sample)
. 
. summ dead1yr [aw=nobs_]

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
     dead1yr |   52535     2785106    .3297433   .0827064          0          1

. gen surv =   1 - r(mean) - fe_

. gen surv_pre = surv*(year<1992)

. *summ dead30d [aw=nobs_]
. *gen surv30d = 1 - r(mean) - fe30d_hosp_ami
. sum parta1y [aw=nobs_]

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
     parta1y |   52535     2785106    23341.19   7383.852          0   98422.11

. gen cost = r(mean)+hosp_cost

. summ drgwgt1y [aw=nobs_]

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    drgwgt1y |   52535     2785106    4.314004   .7587884     .52735    14.2667

. gen drg = r(mean)+hosp_drg

. summ cost [aw=nobs_]

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        cost |   52535     2785106    23298.03    7373.37  -2406.597   97803.61

. scalar meancost=r(mean)

. /* this is the average drg price plus dish plus outlier in 2004 for ami calculated by weiping */
. scalar avgcostperdrg = 6044

. summ drg [aw=nobs_]

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
         drg |   52535     2785106    4.312857   .7637407   .4946769   14.51658

. scalar meandrg=r(mean)

. disp "dollar cost per drg is " meancost/meandrg
dollar cost per drg is 5401.9949

. disp "total cost per drg is "avgcostperdrg
total cost per drg is 6044

. gen moddrg=(avgcostperdrg)*drg

. 
. * Merge income data
. capture drop _merge

. sort hrr

. merge hrr using "/volumes/jss/Staiger Productivity/hrr_names.dta"
variable hrr does not uniquely identify observations in the master data
hrr was int now float

. tab _merge 

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      2,166        4.12        4.12
          2 |          1        0.00        4.12
          3 |     50,369       95.88      100.00
------------+-----------------------------------
      Total |     52,536      100.00

. drop if _merge==2
(1 observation deleted)

. drop _merge

. rename hrrstate state

. sort state year

. merge state year using "/volumes/jss/Staiger Productivity/state_year_inc.dta"
variables state year do not uniquely identify observations in the master data

. tab _merge

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      2,166        4.12        4.12
          2 |         71        0.13        4.25
          3 |     50,369       95.75      100.00
------------+-----------------------------------
      Total |     52,606      100.00

. drop if _merge==2
(71 observations deleted)

. drop _merge

. /* impute income by state & year for providers missing hrr */
. /* use median income for same year and for providers with medicare provider number in same state */
. gen state_mc=int(provider/10000)

. egen medinc = median(income), by(state_mc year)

. replace income=medinc if income==.
income was long now double
(2166 real changes made)

. gen linc = log(income)

. tab f_level_5 if year == 1994 | year == 1995 [aw=nobs_], sum(income)

5 quantiles |                Summary of income
of f_joint1 |        Mean   Std. Dev.       Freq.        Obs.
------------+------------------------------------------------
          1 |   41774.538   5619.9784       81985        1628
          2 |   42344.548   5338.7599       79967        1132
          3 |   42275.713   5089.8396       79901         992
          4 |   42592.558   5309.9683       78438         948
          5 |   44266.596   5211.3671       74182         830
------------+------------------------------------------------
      Total |     42622.9   5383.3127      394473        5530

. tab f_bad_5 if year == 1994 | year == 1995 [aw=nobs_], sum(income)

5 quantiles |                Summary of income
of f_joint2 |        Mean   Std. Dev.       Freq.        Obs.
------------+------------------------------------------------
          1 |    43733.78   5613.1167       83667        1414
          2 |    43404.47   5669.7502       79446        1090
          3 |   42149.812   5211.4602       78563         986
          4 |    42224.21   5027.3022       77342         960
          5 |   41469.448    4990.832       75455        1080
------------+------------------------------------------------
      Total |     42622.9   5383.3127      394473        5530

. 
. /* drop if <5 obs */
. drop if nobs_<5
(2598 observations deleted)

. 
. save temp_6may2014, replace
file temp_6may2014.dta saved

. 
. /* now create graphs */
. /* figure 2 -- aggregate trends */
. anova cost year [aw=nobs_]
(sum of wgt is   2.7776e+06)

                           Number of obs =   49937     R-squared     =  0.2304
                           Root MSE      = 6450.63     Adj R-squared =  0.2301

                  Source |  Partial SS    df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |  6.2177e+11    18  3.4543e+10     830.14     0.0000
                         |
                    year |  6.2177e+11    18  3.4543e+10     830.14     0.0000
                         |
                Residual |  2.0771e+12 49918  41610578.3   
              -----------+----------------------------------------------------
                   Total |  2.6989e+12 49936  54046890.6   

. predict costhat
(option xb assumed; fitted values)

. anova surv year [aw=nobs_]
(sum of wgt is   2.7776e+06)

                           Number of obs =   49937     R-squared     =  0.0696
                           Root MSE      = .071253     Adj R-squared =  0.0692

                  Source |  Partial SS    df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |  18.9531826    18  1.05295459     207.40     0.0000
                         |
                    year |  18.9531826    18  1.05295459     207.40     0.0000
                         |
                Residual |  253.431883 49918  .005076964   
              -----------+----------------------------------------------------
                   Total |  272.385065 49936  .005454683   

. predict survhat
(option xb assumed; fitted values)

. collapse costhat survhat, by(year)

. label var costhat "Expenditures (Left Axis)"

. label var survhat "Survival (Right Axis)"

. #delimit ;
delimiter now ;
. twoway (connected costhat year, sort yaxis(1)) 
>        (line survhat year, sort yaxis(2)), 
>        ytitle(Expenditures $, axis(1)) ytitle(One-Year Survival, axis(2))
>        ytitle(, margin(small) axis(1)) ytitle(, margin(small) axis(2))
>        xtitle(Year, margin(small)) 
>        ylabel(10000(2000)30000, labsize(small) angle(horizontal) nogrid axis(1))
>        ylabel(.56(.02).72, labsize(small) angle(horizontal) nogrid axis(2))
>        xlabel(1986(2)2004)
>        saving(figure2_may2014, replace)
>        ;
(file figure2_may2014.gph saved)

. #delimit cr
delimiter now cr
. graph export figure2_may2014.tif, replace
(file figure2_may2014.tif written in TIFF format)

. 
. /* figures 3 & 4 --  trends in survival and costs/drg by quintile of propensity to adopt */
. /* this uses the original one-factor, f_level1 & f_level1_5, based on bblockers, asa, & reperf12 */
. clear

. use temp_6may2014

. anova cost year*f_level1_5 [aw=nobs_]
(sum of wgt is   2.7776e+06)

                           Number of obs =   49937     R-squared     =  0.2408
                           Root MSE      = 6411.76     Adj R-squared =  0.2394

                  Source |  Partial SS    df       MS           F     Prob > F
         ----------------+----------------------------------------------------
                   Model |  6.4984e+11    94  6.9132e+09     168.16     0.0000
                         |
         year*f_level1_5 |  6.4984e+11    94  6.9132e+09     168.16     0.0000
                         |
                Residual |  2.0490e+12 49842  41110722.8   
         ----------------+----------------------------------------------------
                   Total |  2.6989e+12 49936  54046890.6   

. predict costhat
(option xb assumed; fitted values)

. anova moddrg year*f_level1_5 [aw=nobs_]
(sum of wgt is   2.7776e+06)

                           Number of obs =   49937     R-squared     =  0.4226
                           Root MSE      = 3487.79     Adj R-squared =  0.4215

                  Source |  Partial SS    df       MS           F     Prob > F
         ----------------+----------------------------------------------------
                   Model |  4.4376e+11    94  4.7209e+09     388.08     0.0000
                         |
         year*f_level1_5 |  4.4376e+11    94  4.7209e+09     388.08     0.0000
                         |
                Residual |  6.0631e+11 49842  12164683.4   
         ----------------+----------------------------------------------------
                   Total |  1.0501e+12 49936  21028388.3   

. predict moddrghat
(option xb assumed; fitted values)

. anova surv year*f_level1_5 [aw=nobs_]
(sum of wgt is   2.7776e+06)

                           Number of obs =   49937     R-squared     =  0.0883
                           Root MSE      = .070587     Adj R-squared =  0.0866

                  Source |  Partial SS    df       MS           F     Prob > F
         ----------------+----------------------------------------------------
                   Model |  24.0454557    94   .25580272      51.34     0.0000
                         |
         year*f_level1_5 |  24.0454557    94   .25580272      51.34     0.0000
                         |
                Residual |   248.33961 49842  .004982537   
         ----------------+----------------------------------------------------
                   Total |  272.385065 49936  .005454683   

. predict survhat
(option xb assumed; fitted values)

. collapse costhat moddrghat survhat, by(year f_level1_5)

. #delimit ;
delimiter now ;
. twoway (connect survhat year if f_level1_5==1, sort) 
>        (line survhat year if f_level1_5==2, sort)
>        (line survhat year if f_level1_5==3, sort)
>        (line survhat year if f_level1_5==4, sort)
>        (connect survhat year if f_level1_5==5, sort), 
>        ytitle(One-Year Survival)
>        ytitle(, margin(small))
>        ylabel(.58(.02).72, labsize(small) angle(horizontal) nogrid)
>        xlabel(1986(2)2004)
>        legend(order(1 "Slowest Diffusion Quintile" 2 "2nd Quintile" 3 "Middle Quintile" 4 "4th Quintile"  5 "Fastest Diffusion Quintile"))
>        /* scheme(s2mono) */
>        saving(figure3_may2014, replace)
>        ;
(file figure3_may2014.gph saved)

. graph export figure3_may2014.tif, replace;
(file figure3_may2014.tif written in TIFF format)

. twoway (connect costhat year if f_level1_5==1, sort) 
>        (line costhat year if f_level1_5==2, sort)
>        (line costhat year if f_level1_5==3, sort)
>        (line costhat year if f_level1_5==4, sort)
>        (connect costhat year if f_level1_5==5, sort), 
>        ytitle(One-Year Expenditures (2004$))
>        ytitle(, margin(small))
>        ylabel(10000(2000)30000, labsize(small) angle(horizontal) nogrid)
>        xlabel(1986(2)2004)
>        legend(order(1 "Slowest Diffusion Quintile" 2 "2nd Quintile" 3 "Middle Quintile" 4 "4th Quintile"  5 "Fastest Diffusion Quintile"))
>        /* scheme(s2mono) */
>        saving(figure4a_may2014, replace)
>        ;
(file figure4a_may2014.gph saved)

. graph export figure4a_may2014.tif, replace;
(file figure4a_may2014.tif written in TIFF format)

. twoway (connect moddrghat year if f_level1_5==1, sort) 
>        (line moddrghat year if f_level1_5==2, sort)
>        (line moddrghat year if f_level1_5==3, sort)
>        (line moddrghat year if f_level1_5==4, sort)
>        (connect moddrghat year if f_level1_5==5, sort), 
>        ytitle(Normalized Expenditures (2004$))
>        ytitle(, margin(small))
>        ylabel(10000(2000)30000, labsize(small) angle(horizontal) nogrid)
>        xlabel(1986(2)2004)
>        legend(order(1 "Slowest Diffusion Quintile" 2 "2nd Quintile" 3 "Middle Quintile" 4 "4th Quintile"  5 "Fastest Diffusion Quintile"))
>        /* scheme(s2mono) */
>        saving(figure4b_may2014, replace)
>        ;
(file figure4b_may2014.gph saved)

. graph export figure4b_may2014.tif, replace;
(file figure4b_may2014.tif written in TIFF format)

. #delimit cr
delimiter now cr
. 
. 
. 
. clear

. use temp_6may2014

. anova cost year*f_bad_5 [aw=nobs_]
(sum of wgt is   2.7776e+06)

                           Number of obs =   49937     R-squared     =  0.2636
                           Root MSE      = 6314.87     Adj R-squared =  0.2622

                  Source |  Partial SS    df       MS           F     Prob > F
            -------------+----------------------------------------------------
                   Model |  7.1131e+11    94  7.5671e+09     189.76     0.0000
                         |
            year*f_bad_5 |  7.1131e+11    94  7.5671e+09     189.76     0.0000
                         |
                Residual |  1.9876e+12 49842  39877620.2   
            -------------+----------------------------------------------------
                   Total |  2.6989e+12 49936  54046890.6   

. predict costhat
(option xb assumed; fitted values)

. anova moddrg year*f_bad_5 [aw=nobs_]
(sum of wgt is   2.7776e+06)

                           Number of obs =   49937     R-squared     =  0.4189
                           Root MSE      = 3498.89     Adj R-squared =  0.4178

                  Source |  Partial SS    df       MS           F     Prob > F
            -------------+----------------------------------------------------
                   Model |  4.3990e+11    94  4.6797e+09     382.26     0.0000
                         |
            year*f_bad_5 |  4.3990e+11    94  4.6797e+09     382.26     0.0000
                         |
                Residual |  6.1018e+11 49842  12242249.9   
            -------------+----------------------------------------------------
                   Total |  1.0501e+12 49936  21028388.3   

. predict moddrghat
(option xb assumed; fitted values)

. anova surv year*f_bad_5 [aw=nobs_]
(sum of wgt is   2.7776e+06)

                           Number of obs =   49937     R-squared     =  0.0772
                           Root MSE      = .071015     Adj R-squared =  0.0755

                  Source |  Partial SS    df       MS           F     Prob > F
            -------------+----------------------------------------------------
                   Model |  21.0284524    94  .223706941      44.36     0.0000
                         |
            year*f_bad_5 |  21.0284524    94  .223706941      44.36     0.0000
                         |
                Residual |  251.356613 49842  .005043068   
            -------------+----------------------------------------------------
                   Total |  272.385065 49936  .005454683   

. predict survhat
(option xb assumed; fitted values)

. collapse costhat moddrghat survhat, by(year f_bad_5)

. 
. #delimit ;
delimiter now ;
. twoway (connect survhat year if f_bad==1, sort) 
>        (line survhat year if f_bad==2, sort)
>        (line survhat year if f_bad==3, sort)
>        (line survhat year if f_bad==4, sort)
>        (connect survhat year if f_bad==5, sort), 
>        ytitle(One-Year Survival)
>        ytitle(, margin(small))
>        ylabel(.58(.02).72, labsize(small) angle(horizontal) nogrid)
>        xlabel(1986(2)2004)
>        legend(order(1 "Slowest Diffusion Quintile" 2 "2nd Quintile" 3 "Middle Quintile" 4 "4th Quintile"  5 "Fastest Diffusion Quintile"))
>        /* scheme(s2mono) */
>        saving(figure3bad_may2014, replace)
>        ;
(file figure3bad_may2014.gph saved)

. graph export figure3bad_may2014.tif, replace;
(file figure3bad_may2014.tif written in TIFF format)

. twoway (connect costhat year if f_bad==1, sort) 
>        (line costhat year if f_bad==2, sort)
>        (line costhat year if f_bad==3, sort)
>        (line costhat year if f_bad==4, sort)
>        (connect costhat year if f_bad==5, sort), 
>        ytitle(One-Year Expenditures (2004$))
>        ytitle(, margin(small))
>        ylabel(10000(2000)30000, labsize(small) angle(horizontal) nogrid)
>        xlabel(1986(2)2004)
>        legend(order(1 "Slowest Diffusion Quintile" 2 "2nd Quintile" 3 "Middle Quintile" 4 "4th Quintile"  5 "Fastest Diffusion Quintile"))
>        /* scheme(s2mono) */
>        saving(figure4abad_may2014, replace)
>        ;
(file figure4abad_may2014.gph saved)

. graph export figure4abad_may2014.tif, replace;
(file figure4abad_may2014.tif written in TIFF format)

. twoway (connect moddrghat year if f_bad==1, sort) 
>        (line moddrghat year if f_bad==2, sort)
>        (line moddrghat year if f_bad==3, sort)
>        (line moddrghat year if f_bad==4, sort)
>        (connect moddrghat year if f_bad==5, sort), 
>        ytitle(Normalized Expenditures (2004$))
>        ytitle(, margin(small))
>        ylabel(10000(2000)30000, labsize(small) angle(horizontal) nogrid)
>        xlabel(1986(2)2004)
>        legend(order(1 "Slowest Diffusion Quintile" 2 "2nd Quintile" 3 "Middle Quintile" 4 "4th Quintile"  5 "Fastest Diffusion Quintile"))
>        /* scheme(s2mono) */
>        saving(figure4bbad_may2014, replace)
>        ;
(file figure4bbad_may2014.gph saved)

. graph export figure4bbad_may2014.tif, replace;
(file figure4bbad_may2014.tif written in TIFF format)

. #delimit cr
delimiter now cr
. 
. 
. /* figure 5 --  trends in variance across hospitals (sigma convergence) */
. /* (note that this weights by nobs_^2 to get the variance) */
. clear

. use temp_6may2014

. gen adjvar=.
(49937 missing values generated)

. gen noisevar = (rmse_hosp^2)/nobs_

. forval y = 1986/2004 {
  2.  summ surv if year==`y' [aw=nobs_^2]
  3.  scalar totvar = r(Var)
  4.  summ noisevar [aw=nobs_^2] if year==`y'
  5.  replace adjvar = totvar-r(mean) if year==`y'
  6.  }

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2344      734331    .5948269   .1065231  -.0212906   1.082159

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2344      734331    .0093257   .0059823   .0026146   .0392188
(2344 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2323      707019    .6057315   .1065254  -.0403899   1.074193

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2323      707019    .0094924   .0060209   .0025802   .0392188
(2323 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2320      742988     .616566   .1054323   .0181201   1.081826

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2320      742988    .0092268   .0059119   .0026499   .0392188
(2320 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2293      720732    .6293606   .1054546  -.0945841   1.074203

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2293      720732    .0093376   .0059297   .0026862   .0392188
(2293 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2323      762336    .6393506   .1018683   .0451271     1.1153

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2323      762336    .0090112    .005999    .002514   .0392188
(2323 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2389     1080683    .6413728   .0927796  -.1010905   1.095386

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2389     1080683    .0075189    .005337    .002001   .0392188
(2389 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    24693941    .6522235   .0521361   .2938212   .9553888

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    24693941      .00164   .0012715   .0003686   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    23950169    .6621252   .0509353   .2444783   .9039847

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    23950169    .0016457   .0013158   .0003721   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    23642328    .6709268    .050774   .2802704   1.035336

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    23642328    .0016458   .0013376   .0003771   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    23570525    .6751552   .0507246   .2769785   1.031351

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    23570525     .001631   .0013607   .0004094   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    23611839    .6795609   .0500249   .2076631   1.088055

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    23611839    .0016127   .0013794   .0003946   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    22599770    .6816881   .0503442   .2950688   1.122571

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    22599770    .0016396   .0014202    .000455   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    23144341    .6785026   .0518958   .2579622   1.038471

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    23144341    .0016073   .0014182   .0004035   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    24179482    .6800676   .0537244   .2302468   1.074131

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    24179482    .0015656   .0013953   .0004018   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    26164513     .683126   .0547414   .2236729   1.005266

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    26164513    .0014931   .0013546   .0003296   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    27013949    .6848091   .0553635   .2408731   1.167413

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    27013949    .0014675   .0013352   .0002998   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    29397804    .6908516   .0508624    .289846   1.013255

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    29397804    .0013788     .00131   .0002543   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    28639179     .694675   .0534137   .2853039    1.12784

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    28639179     .001377   .0013479   .0002511   .0392188
(2765 real changes made)

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        surv |    2765    25212811    .7017092   .0560442   .1797135   1.135091

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
    noisevar |    2765    25212811    .0014431   .0014612   .0002577   .0392188
(2765 real changes made)

. 
. collapse adjvar, by(year)

. gen adjsd = sqrt(adjvar)

. list year adjsd

     +-----------------+
     | year      adjsd |
     |-----------------|
  1. | 1986   .0449602 |
  2. | 1987   .0430726 |
  3. | 1988   .0434641 |
  4. | 1989   .0422258 |
  5. | 1990   .0369589 |
     |-----------------|
  6. | 1991   .0330025 |
  7. | 1992   .0328356 |
  8. | 1993   .0308004 |
  9. | 1994   .0305318 |
 10. | 1995   .0306923 |
     |-----------------|
 11. | 1996   .0298296 |
 12. | 1997   .0299158 |
 13. | 1998   .0329527 |
 14. | 1999   .0363415 |
 15. | 2000    .038775 |
     |-----------------|
 16. | 2001   .0399697 |
 17. | 2002   .0347585 |
 18. | 2003   .0384187 |
 19. | 2004   .0412045 |
     +-----------------+

. #delimit ;
delimiter now ;
. twoway (line adjsd year, sort), 
>        ytitle(Standard Deviation of Hospital Survival)
>        ytitle(, margin(small))
>        ylabel(0(.01).06, labsize(small) angle(horizontal) nogrid)
>        xlabel(1986(2)2004)
>        scheme(s2mono)
>        saving(figure5_may2014, replace)
>        ;
(file figure5_may2014.gph saved)

. #delimit cr
delimiter now cr
. graph export figure5_may2014.tif, replace
(file figure5_may2014.tif written in TIFF format)

. 
. * regressions:
. clear

. use temp_6may2014

. gen lcost = log(cost)
(5 missing values generated)

. gen ldrg  = log(drg)

. gen lmdrg = log(moddrg)

. 
. /* this merges on surgical rates from ccp to see if they are more correlated with stent adoption */
. sort provider

. merge provider using ccp_hosp_surgrates
variable provider does not uniquely identify observations in the master data

. tab _merge

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          2 |         47        0.09        0.09
          3 |     49,937       99.91      100.00
------------+-----------------------------------
      Total |     49,984      100.00

. drop _merge

. corr avdif cath30d revasc reper12 f_level [aw=nobs_]
(sum of wgt is   1.6493e+06)
(obs=19756)

             |    avdif  cath30d reva~30d  reper12  f_level
-------------+---------------------------------------------
       avdif |   1.0000
     cath30d |   0.0566   1.0000
   revasc30d |   0.0713   0.8969   1.0000
     reper12 |  -0.0885   0.1990   0.2306   1.0000
     f_level |   0.1884   0.4115   0.4154   0.0543   1.0000


. 
. /* asian tigers analysis */
. gen insamp_tigers=(year==1994|year==1995|year==2003|year==2004)&(f_level1_5==1|f_level1_5==5)&(avdif_5==1|avdif_5==5)

. gen change_11 = (f_level1_5==1 & avdif_5==1) if insamp_tigers==1
(49284 missing values generated)

. gen change_15 = (f_level1_5==1 & avdif_5==5) if insamp_tigers==1
(49284 missing values generated)

. gen change_51 = (f_level1_5==5 & avdif_5==1) if insamp_tigers==1
(49284 missing values generated)

. gen change_55 = (f_level1_5==5 & avdif_5==5) if insamp_tigers==1
(49284 missing values generated)

. foreach var in change_11 change_15 change_51 change_55 {
  2.  gen post`var'=`var'*(year==2003|year==2004) if insamp_tigers==1
  3.  }
(49284 missing values generated)
(49284 missing values generated)
(49284 missing values generated)
(49284 missing values generated)

. /* here are means in 1994-1995 */
. reg surv change_* [aw=nobs_] if year==1994 | year==1995, nocon cluster(provider)
(sum of wgt is   3.0958e+04)

Linear regression                                      Number of obs =     350
                                                       F(  4,   174) = 9350.85
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.9936
                                                       Root MSE      =  .05461

                             (Std. Err. adjusted for 175 clusters in provider)
------------------------------------------------------------------------------
             |               Robust
        surv |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   change_11 |   .6522714   .0082119    79.43   0.000     .6360637    .6684791
   change_15 |   .6545975    .016996    38.51   0.000     .6210527    .6881422
   change_51 |   .6860891   .0060164   114.04   0.000     .6742146    .6979636
   change_55 |   .6842868     .00531   128.87   0.000     .6738064    .6947672
------------------------------------------------------------------------------

. /* here are means in 2003-2004 */
. reg surv change_* [aw=nobs_] if year==2003 | year==2004, nocon cluster(provider)
(sum of wgt is   3.8088e+04)

Linear regression                                      Number of obs =     350
                                                       F(  4,   174) = 9025.15
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.9944
                                                       Root MSE      =  .05321

                             (Std. Err. adjusted for 175 clusters in provider)
------------------------------------------------------------------------------
             |               Robust
        surv |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   change_11 |   .6912626   .0087701    78.82   0.000     .6739531    .7085721
   change_15 |   .7100176   .0119485    59.42   0.000     .6864349    .7336002
   change_51 |   .7007827   .0069535   100.78   0.000     .6870587    .7145068
   change_55 |   .7192715   .0056511   127.28   0.000     .7081179    .7304251
------------------------------------------------------------------------------

. /* here are the difs -- coefficients on the post variables */
. reg surv change_* postchange_* [aw=nobs_] if year==1994 | year==1995 | year==2003 | year==2004, nocon cluster(provider)
(sum of wgt is   6.9046e+04)

Linear regression                                      Number of obs =     700
                                                       F(  8,   174) = 7105.29
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.9941
                                                       Root MSE      =  .05384

                             (Std. Err. adjusted for 175 clusters in provider)
------------------------------------------------------------------------------
             |               Robust
        surv |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   change_11 |   .6522714   .0082178    79.37   0.000     .6360521    .6684907
   change_15 |   .6545975   .0170081    38.49   0.000     .6210287    .6881663
   change_51 |   .6860891   .0060207   113.95   0.000     .6742061    .6979721
   change_55 |   .6842868   .0053139   128.77   0.000     .6737989    .6947747
postchang~11 |   .0389912   .0093795     4.16   0.000      .020479    .0575033
postchang~15 |   .0554201   .0164423     3.37   0.001     .0229681    .0878721
postchang~51 |   .0146936   .0084429     1.74   0.084    -.0019701    .0313574
postchang~55 |   .0349847    .006215     5.63   0.000     .0227182    .0472512
------------------------------------------------------------------------------

. test postchange_15=postchange_51

 ( 1)  postchange_15 - postchange_51 = 0

       F(  1,   174) =    4.86
            Prob > F =    0.0289

. test postchange_15=postchange_51=postchange_11=postchange_55

 ( 1)  postchange_15 - postchange_51 = 0
 ( 2)  - postchange_11 + postchange_15 = 0
 ( 3)  postchange_15 - postchange_55 = 0

       F(  3,   174) =    2.34
            Prob > F =    0.0752

. test postchange_11=postchange_55

 ( 1)  postchange_11 - postchange_55 = 0

       F(  1,   174) =    0.13
            Prob > F =    0.7222

. tab f_level_5 avdif_5 if insamp & year==1994

         5 |
 quantiles |
        of | 5 quantiles of avdif 
 f_joint1  |         1          5 |     Total
-----------+----------------------+----------
         1 |        46         12 |        58 
         2 |         6          5 |        11 
         4 |        10          3 |        13 
         5 |        43         50 |        93 
-----------+----------------------+----------
     Total |       105         70 |       175 


. tab f_level_5 avdif_5 if insamp [fw=nobs_]

         5 |
 quantiles |
        of | 5 quantiles of avdif 
 f_joint1  |         1          5 |     Total
-----------+----------------------+----------
         1 |    12,451      3,656 |    16,107 
         2 |     2,622      1,254 |     3,876 
         4 |     3,606      1,191 |     4,797 
         5 |    15,180     29,086 |    44,266 
-----------+----------------------+----------
     Total |    33,859     35,187 |    69,046 


. /* here are the difs in ldrg -- coefficients on the post variables */
. reg ldrg change_* postchange_* [aw=nobs_] if year==1994 | year==1995 | year==2003 | year==2004, nocon cluster(provider)
(sum of wgt is   6.9046e+04)

Linear regression                                      Number of obs =     700
                                                       F(  8,   174) = 5025.53
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.9932
                                                       Root MSE      =  .12408

                             (Std. Err. adjusted for 175 clusters in provider)
------------------------------------------------------------------------------
             |               Robust
        ldrg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   change_11 |   1.412271    .018504    76.32   0.000      1.37575    1.448792
   change_15 |   1.400285   .0229297    61.07   0.000     1.355028    1.445541
   change_51 |   1.393877   .0192798    72.30   0.000     1.355825     1.43193
   change_55 |   1.397459    .016054    87.05   0.000     1.365774    1.429145
postchang~11 |   .1477991   .0168567     8.77   0.000     .1145291    .1810691
postchang~15 |   .1757711   .0388824     4.52   0.000     .0990293    .2525129
postchang~51 |   .1410557      .0199     7.09   0.000     .1017791    .1803322
postchang~55 |   .1759553   .0151475    11.62   0.000     .1460587    .2058518
------------------------------------------------------------------------------

. test postchange_15=postchange_51

 ( 1)  postchange_15 - postchange_51 = 0

       F(  1,   174) =    0.63
            Prob > F =    0.4278

. test postchange_15=postchange_51=postchange_11=postchange_55

 ( 1)  postchange_15 - postchange_51 = 0
 ( 2)  - postchange_11 + postchange_15 = 0
 ( 3)  postchange_15 - postchange_55 = 0

       F(  3,   174) =    0.90
            Prob > F =    0.4435

. test postchange_11=postchange_55

 ( 1)  postchange_11 - postchange_55 = 0

       F(  1,   174) =    1.54
            Prob > F =    0.2158

. 
. 
. global minsize = 50

. 
. tsset provider year
       panel variable:  provider (unbalanced)
        time variable:  year, 1986 to 2004, but with gaps
                delta:  1 unit

. * First a quick test to see if this occurs in teaching hospitals
. reg surv  ldrg f_level1  year [aw=nobs_] if nobs_ >=5 & teaching_hospital === 1, cluster(provider)
teaching_hospital= invalid name
r(198);

end of do-file

r(198);

. sum teaching

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
teaching_h~l |     49937    .0824239    .2750121          0          1

. reg surv  ldrg f_level1  year [aw=nobs_] if nobs_ >=5 & teaching_hospital == 1, cluster(provider)
(sum of wgt is   3.7877e+05)

Linear regression                                      Number of obs =    4116
                                                       F(  3,   220) =   63.21
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.0763
                                                       Root MSE      =  .06161

                             (Std. Err. adjusted for 221 clusters in provider)
------------------------------------------------------------------------------
             |               Robust
        surv |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        ldrg |   .0029732   .0123235     0.24   0.810     -.021314    .0272604
    f_level1 |   .0149495     .00496     3.01   0.003     .0051743    .0247248
        year |   .0034765   .0004441     7.83   0.000     .0026013    .0043517
       _cons |  -6.285593   .8728995    -7.20   0.000    -8.005908   -4.565278
------------------------------------------------------------------------------

